<?php

use think\migration\Seeder;

class InitData extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run() :void
    {
        // 添加支付渠道
        $this->table("payment_channels")->insert([
            'channel_name'          => '杉德钱包直连',
            'pay_code'              => 'ShanDeDirect',
            'channel_code'          => 'shande',
            'pay_url'               => 'https://faspay-oss.sandpay.com.cn/pay/h5/cloud',
            'find_url'              => 'https://cap.sandpay.com.cn/v4/elecaccount/ceas.elec.member.status.query',
            'channel_rate'          => '3.5'
        ])->save();

        // 添加支付方式
        foreach ([
            ['method_name'=>'微信', 'method_code'=>'wxpay', 'is_show'=>true],
            ['method_name'=>'支付宝', 'method_code'=>'alipay', 'is_show'=>true],
            ['method_name'=>'杉德钱包', 'method_code'=>'shande', 'is_show'=>true],
            ['method_name'=>'卡密', 'method_code'=>'cardpay', 'is_show'=>true],
        ] as $v) {
            $this->table("payment_methods")->insert($v)->save();
        }
        
        // 添加商户
        $this->table("shops")->insert([
            'shop_name'    => 'gogo',   
            'shop_code'    => '00001',  
            'company_main' => '淼佳互娱',  
            'shop_status'  => true,
            'create_time'  => date('Y-m-d H:i:s'),
            'update_time'  => date('Y-m-d H:i:s')
        ])->save();

        // 添加商户
        $this->table("shop_payments")->insert([
            'shop_id'               => 1,
            'channel_id'            => 1,
            'method_id'             => 1,
            'appid'                 => '6888802124093',
            'status'                =>  true,
            'private_key'           => 'payfile/shande/6888802124093.pfx',
            'public_key'            => 'payfile/shande/sand_pro.cer',
            'notify_url'            => 'http://183.221.111.185:8002/api/charge/sdd/notify',
            'return_url'            => 'http://183.221.111.185:8002',
            'settle_secret'         => '147258369'
        ])->save();

        // 添加商户支付方式
        $this->table("shop_payment_methods")->insert([
            'shop_id'               => 1,
            'method_id'             => 3,
            'status'                =>  true,
            'pay_rate'              => 3.5
        ])->save();
    }
}